require 'ruby-hackernews'
require 'rhn/apigen'


class HN
  def hotpage
    RubyHackernews::Entry.all.map {|entry|
      {
        :id => entry.id.to_i,
        :title => entry.link.title,
        :link => entry.link.href,
        :comments_count => entry.comments_count.to_i,
        :voting => entry.voting.score.to_i,
        :user => entry.user.name
      }
    }
  end
end

ApiGen::AccessManager.register HN, "hotpage"
